package com.yequan.hbb.view.fragment.lhp;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.yequan.hbb.R;
import com.yequan.hbb.app.MyApplication;

/**
 * Created by Administrator on 2016/10/17.
 */

public class WebViewFragment  extends Fragment {

    private WebView web_view;
    private ImageView left;
    private ImageView right;
    private TextView title;

    public WebViewFragment() {
    }

    public static WebViewFragment  instance(String title,String link){

        WebViewFragment fragment = new WebViewFragment();
        Bundle bundle = new Bundle();
        bundle.putString("link",link);
        bundle.putString("title",title);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View inflate = inflater.inflate(R.layout.wl_l_hp_webview, container, false);

        return inflate;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        web_view = ((WebView) view.findViewById(R.id.web_view));
        Bundle arguments = getArguments();
        String link = arguments.getString("link");

        if (!TextUtils.isEmpty(link)) {
            web_view.loadUrl(link);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        MyApplication.main.findViewById(R.id.main_rg).setVisibility(View.VISIBLE);
        MyApplication.main.findViewById(R.id.rl).setVisibility(View.VISIBLE);
    }
}
